
import java.io.*;

public class QuickSortRUN
{
	private final static String strQuestion = "\nChoose how to perform :\n\n1 - Not Random\n2 - Random\n3 - Recursive\n\nChoice = ";

	public static void main(String[] args)
	{

		QuickSortCLS myQuickSort = new QuickSortCLS();
		BufferedReader strBuff = new BufferedReader(new InputStreamReader(System.in));
		int ListaDados[] = {10,3,2,4,6,7,8,9,5,1};
		int listaLength = ListaDados.length - 1;

        System.out.print(strQuestion);
		
		String strChoice = null;
		int strToInt = 0;

		while(!(strToInt == 1 || strToInt == 2 || strToInt == 3))
		{
			try
			{
				strChoice = strBuff.readLine();
				strToInt = Integer.parseInt(strChoice);
				System.out.print("\nAgain :\n");
			}
			catch (IOException ioe)
			{
				System.out.println("IO error trying to read your name!");
				System.exit(1);
			}
		}

		System.out.println();
		System.out.println("ANTES DO INSERTION SORT :\n");  

		for(int i = 0; i < ListaDados.length; i++)
		{
			System.out.print(ListaDados[i]+"  ");
		}
		
		System.out.println();

		switch(strToInt)
		{
			case 1:	System.out.println("\nQuickSort");
					myQuickSort.QuickSort(ListaDados, 0, listaLength);
					break;
			case 2: System.out.println("\nRandomized Quicksort");
					myQuickSort.RandomizedQuicksort(ListaDados, 0, listaLength);
					break;
			case 3: System.out.println("\nTail Recursive Quicksort");
					myQuickSort.TailRecursiveQuicksort(ListaDados, 0, listaLength);
					break;
			default:
					break;
		}

		System.out.println();
		System.out.print("DEPOIS DO INSERTION SORT :\n\n");  
		
		for(int i = 0; i <ListaDados.length; i++)
		{
			System.out.print(ListaDados[i]+"  ");
		}
		System.out.println();
	}
}
